package code;

import java.util.Scanner;

public class OneEdit_day02 {
    public static void main(String[] args) {
        Boolean result = oneEdit();

    }
    private static boolean oneEdit() {
        Scanner sc = new Scanner(System.in);
        String first=sc.nextLine();
        String second=sc.nextLine();
        sc.close();
        int len1 = first.length();
        int len2 = second.length();

        // 长度相差超过1，则不可能通过一次编辑使两个字符串相等
        if (Math.abs(len1 - len2) > 1) {
            return false;
        }

        int i = 0, j = 0;
        int no_equal = 0;

        while (i < len1 && j < len2) {
            if (first.charAt(i) != second.charAt(j)) {
                no_equal++;
                if (no_equal > 1) {
                    return false;
                }

                // 移动较长字符串的指针
                if (len1 > len2) {
                    i++;
                } else if (len1 < len2) {
                    j++;
                } else {
                    i++;
                    j++;
                }
            } else {
                i++;
                j++;
            }
        }

        // 处理剩余字符
        if (i < len1 || j < len2) {
            no_equal++;
        }

        return no_equal <= 1;
    }
}
